home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_084 / ed / doprnt.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  81 lines

  1. /*
  2.  * Copyright 1987 Brian Beattie Rights Reserved.
  3.  *
  4.  * Permission to copy and/or distribute granted under the
  5.  * following conditions:
  6.  *
  7.  * 1). No charge may be made other than resonable charges
  8.  *    for reproduction.
  9.  *
  10.  * 2). This notice must remain intact.
  11.  *
  12.  * 3). No further restrictions may be added.
  13.  *
  14.  */
  15. #include <stdio.h>
  16. #include "tools.h"
  17. #include "ed.h"
  18.  
  19. doprnt(from, to)
  20. int    from, to;
  21. {
  22.     int    i;
  23.  
  24.     from = from < 1 ? 1 : from;
  25.     to = to > lastln ? lastln : to;
  26.         
  27.     if(to != 0)
  28.     {
  29.         for(i = from; i <= to; i++)
  30.             prntln(gettxt(i), lflg, (nflg ? i : 0));
  31.         curln = to;
  32.     }
  33.  
  34.     return(0);
  35. }
  36.  
  37. prntln(str, vflg, lin)
  38. char    *str;
  39. int    vflg, lin;
  40. {
  41.     if(lin)
  42.         fprintf(stdout,"%7d ",lin);
  43.     while(*str && *str != NL)
  44.     {
  45.         if(*str < ' ' || *str >= 0x7f)
  46.         {
  47.             switch(*str)
  48.             {
  49.             case '\t':
  50.                 if(vflg)
  51.                     putcntl(*str, stdout);
  52.                 else
  53.                     putc(*str, stdout);
  54.                 break;
  55.  
  56.             case DEL:
  57.                 putc('^', stdout);
  58.                 putc('?', stdout);
  59.                 break;
  60.  
  61.             default:
  62.                 putcntl(*str, stdout);
  63.                 break;
  64.             }
  65.         } else
  66.             putc(*str, stdout);
  67.         str++;
  68.     }
  69.     if(vflg)
  70.         putc('$',stdout);
  71.     putc('\n', stdout);
  72. }
  73.  
  74. putcntl(c, stream)
  75. char    c;
  76. FILE    *stream;
  77. {
  78.     putc('^', stream);
  79.     putc((c&31)|'@', stream);
  80. }
  81.